/* eslint-disable @typescript-eslint/no-empty-object-type */

// import axios from 'axios';
import { baseRequestClient, requestClient } from '#/api/request';

export namespace CalplanApi {
  export interface CalplanListParams {
    pageNum: number;
    pageSize: number;
  }
  export interface CalplanListParams2 {
    pageNum: number;
    pageSize: number;
    planId: number;
  }
  export interface CalplanListParams3 {
    pageNum: number;
    pageSize: number;
    planId: number;
    calendarType: string;
  }
  export interface CalplanListParams4 {
    teamCode: string;
    teamId: number;
    planId: number;
    calendarType: string;
    teamName: string;
  }
  export interface Params {}
  export interface Row {
    searchValue: null;
    createBy: string;
    createTime: string;
    updateBy: string;
    updateTime: null | string;
    remark: string;
    params: Params;
    planId: number;
    planCode: string;
    planName: string;
    calendarType: string;
    startDate: string;
    endDate: string;
    shiftType: string;
    shiftMethod: string;
    shiftCount: number;
    status: string;
    attr1: null;
    attr2: null;
    attr3: number;
    attr4: number;
  }
  export interface Row1 {
    searchValue: null;
    createBy: string;
    createTime: null;
    updateBy: string;
    updateTime: null;
    remark: string;
    params: Params;
    shiftId: number;
    planId: number;
    orderNum: number;
    shiftName: string;
    startTime: string;
    endTime: string;
    attr1: null;
    attr2: null;
    attr3: number;
    attr4: number;
  }
  export interface Row2 {
    searchValue: null;
    createBy: string;
    createTime: string;
    updateBy: string;
    updateTime: null;
    remark: string;
    params: Params;
    recordId: number;
    planId: number;
    teamId: number;
    teamCode: string;
    teamName: string;
    attr1: null;
    attr2: null;
    attr3: number;
    attr4: number;
  }
  export interface CalplanListResult {
    total: number;
    rows: Row[];
    code: number;
    msg: string;
  }
  export interface CalShiftListResult {
    total: number;
    rows: Row1[];
    code: number;
    msg: string;
  }
  export interface CalPlanteamListResult {
    total: number;
    rows: Row2[];
    code: number;
    msg: string;
  }
}

// 获取排班计划列表
export const getCalplanList = (data: CalplanApi.CalplanListParams) => {
  return requestClient.get<CalplanApi.CalplanListResult>(
    '/mes/cal/calplan/list',
    {
      params: data,
    },
  );
};
// 获取班次列表
export const getShiftList = (data: CalplanApi.CalplanListParams2) => {
  return requestClient.get<CalplanApi.CalShiftListResult>(
    '/mes/cal/shift/list',
    {
      params: data,
    },
  );
};
// 获取班组列表
export const getPlanteamList = (data: CalplanApi.CalplanListParams3) => {
  return requestClient.get<CalplanApi.CalPlanteamListResult>(
    '/mes/cal/planteam/list',
    {
      params: data,
    },
  );
};

// 新增排班计划
export const addCalplan = (data: CalplanApi.Row) =>
  requestClient.post<CalplanApi.CalplanListResult>('/mes/cal/calplan', data);

// 修改排班计划
export const updateCalplan = (data: CalplanApi.Row) =>
  requestClient.put<CalplanApi.CalplanListResult>('/mes/cal/calplan', data);

// 删除排班计划
export const deleteCalplan = (id: string) =>
  requestClient.delete<CalplanApi.CalplanListResult>(`/mes/cal/calplan/${id}`);

// 新增班次
export const addShift = (data: CalplanApi.Row1) =>
  requestClient.post<CalplanApi.CalShiftListResult>('/mes/cal/shift', data);

// 修改班次
export const updateShift = (data: CalplanApi.Row1) =>
  requestClient.put<CalplanApi.CalShiftListResult>('/mes/cal/shift', data);

// 删除班次
export const deleteShift = (id: string) =>
  requestClient.delete<CalplanApi.CalShiftListResult>(`/mes/cal/shift/${id}`);

// 新增班组
export const addPlanteam = (data: CalplanApi.CalplanListParams4) =>
  requestClient.post<CalplanApi.CalShiftListResult>('/mes/cal/planteam', data);
// 删除班组
export const deletePlanteam = (id: string) =>
  requestClient.delete<CalplanApi.CalPlanteamListResult>(
    `/mes/cal/planteam/${id}`,
  );

// 自动生成班组编号
export const getPlanCode = () =>
  baseRequestClient.get<any>('/system/autocode/get/CAL_PLAN_CODE');
